package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjPubUpScrap;
import com.koron.css2.newProjectCenter.mapper.PjPubUpScrapMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import com.koron.util.Tools;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * @Author: 苏小龙
 * @CreateTime: 2024-12-04
 * @Description: 材料报废遗失
 * @Version: 1.0
 */
public class PjPubUpScrapSave implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjPubUpScrap pubUpInvoice = JsonUtils.objectToPojo(req.getData(), PjPubUpScrap.class);
            PjPubUpScrapMapper pjPubUpInvoiceMapper= factory.getMapper(PjPubUpScrapMapper.class);
            // 1. id
            pubUpInvoice.setId(Tools.getObjectId());
            // 1. updateTime,updateAccount,updateName
            pubUpInvoice.setCreateInfo(userInfo);
            // 2. 新增数据
            pjPubUpInvoiceMapper.insert(pubUpInvoice);
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "保存成功", null);
        } catch (Exception e) {
            factory.close(false);
            logger.error("材料报废遗失"+e.getMessage(), e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL, "保存失败", null);
        }
    }
}
